package com.LC._120;

import java.util.ArrayList;
import java.util.List;

class Solution {
    public int minimumTotal(List<List<Integer>> triangle) {
        int n = triangle.size();
        int[] dp = new int[n + 1];
        for (int i = n - 1; i >= 0; i--) {//
            for (int j = 0; j <= i; j++) {
                dp[j] = Math.min(dp[j], dp[j + 1]) + triangle.get(i).get(j);
            }
        }
        return dp[0];
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        List<List<Integer>> nums;
//        [[2],[3,4],[6,5,7],[4,1,8,3]]
        nums=new ArrayList<>();
        System.out.println(solution.minimumTotal(nums));
    }
}